package com.wuxinwudai.android.sample.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.StringRes;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;

import com.wuxinwudai.android.app.BaseActivity;
import com.wuxinwudai.android.sample.R;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MainActivity extends BaseActivity {

    @BindView(R.id.ll)
    LinearLayout ll;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        ll.addView(createButton(R.string.title_test_cgv,TestCgvActivity.class));
        ll.addView(createButton(R.string.title_test_ctv,TestCtvActivity.class));
        ll.addView(createButton(R.string.title_test_csc,TestCscActivity.class));
    }

    private Button createButton(@StringRes int txt, final Class<?> activity){
        Button btn = new Button(this);
        btn.setText(txt);
        btn.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this,activity));
            }
        });
        return btn;
    }
}
